package com.xqls.controller;

import com.xqls.biz.DictionaryBiz;
import com.xqls.biz.FluggasDischargeMimRecordBiz;
import com.xqls.util.CommonPage;
import com.xqls.util.CommonResult;
import com.xqls.util.DictionaryEnums;
import com.xqls.util.GetKeyByValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * Created by hdg on 2017/7/17.
 */
@Controller
@RequestMapping(value = "/fluggasrecord")
public class FluggasRecordController {
    @Autowired
    private FluggasDischargeMimRecordBiz fluggasminBiz;

    @Autowired private DictionaryBiz dictionaryBiz;
    /*分钟记录*/
    @RequestMapping(value = "/fluggasrecordminList")
    public ModelAndView fluggasRecordminList() {
        ModelAndView view = new ModelAndView("fluggasRecord/fluggasminList");
        String url = null;
        String title = null;
        Map<Integer, String> map = dictionaryBiz.queryDictionaryByParent(  DictionaryEnums.COMPANY_TYPE.getCode());
        view.addObject("deviceType", GetKeyByValue.getKey(map, "废气排放口"));
        view.addObject("count",fluggasminBiz.queryAll());
        view.addObject("columns", CommonPage.setColumnToPage(null,
                null, url, title));
        return view;
    }

    /*分钟记录*/
    @RequestMapping("/FluggasminRecordData")
    @ResponseBody
    public CommonResult FluggasminRecordData(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response) {
        CommonResult commonResult = this.fluggasminBiz.queryMinFluggasDischargeRealdataRecord(commonPage,request,response);
        if (commonResult.getIsSuccess()) {
            commonResult.setData(commonPage);
        }
        return commonResult;
    }
    /*小时记录*/
    @RequestMapping(value = "/fluggasrecordhourList")
    public ModelAndView fluggasRecordhourList() {
        ModelAndView view = new ModelAndView("fluggasRecord/fluggashourList");
        String url = null;
        String title = null;
        Map<Integer, String> map = dictionaryBiz.queryDictionaryByParent(  DictionaryEnums.COMPANY_TYPE.getCode());
        view.addObject("deviceType", GetKeyByValue.getKey(map, "废气排放口"));
        view.addObject("count",fluggasminBiz.queryAll());
        view.addObject("columns", CommonPage.setColumnToPage(null,
                null, url, title));
        return view;
    }
    /*小时记录*/
    @RequestMapping("/FluggashourRecordData")
    @ResponseBody
    public CommonResult FluggashourRecordData(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response) {
        CommonResult commonResult = this.fluggasminBiz.queryHourFluggasDischargeRealdataRecord(commonPage,request,response);
        if (commonResult.getIsSuccess()) {
            commonResult.setData(commonPage);
        }
        return commonResult;
    }

    /*天记录*/
    @RequestMapping(value = "/fluggasRecorddayList")
    public ModelAndView fluggasRecorddayList() {
        ModelAndView view = new ModelAndView("fluggasRecord/fluggasdayList");
        String url = null;
        String title = null;
        Map<Integer, String> map = dictionaryBiz.queryDictionaryByParent(  DictionaryEnums.COMPANY_TYPE.getCode());
        view.addObject("deviceType", GetKeyByValue.getKey(map, "废气排放口"));
        view.addObject("count",fluggasminBiz.queryAll());
        view.addObject("columns", CommonPage.setColumnToPage(null,
                null, url, title));
        return view;
    }
    /*天记录*/
    @RequestMapping("/FluggasdayRecordData")
    @ResponseBody
    public CommonResult FluggasdayRecordData(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response) {
        CommonResult commonResult = this.fluggasminBiz.queryDayFluggasDischargeRealdataRecord(commonPage,request,response);
        if (commonResult.getIsSuccess()) {
            commonResult.setData(commonPage);
        }
        return commonResult;
    }

    /*月记录*/
    @RequestMapping(value = "/fluggasRecordmothList")
    public ModelAndView fluggasRecordmothList() {
        ModelAndView view = new ModelAndView("fluggasRecord/fluggasmothList");
        String url = null;
        String title = null;
        Map<Integer, String> map = dictionaryBiz.queryDictionaryByParent(  DictionaryEnums.COMPANY_TYPE.getCode());
        view.addObject("deviceType", GetKeyByValue.getKey(map, "废气排放口"));
        view.addObject("count",fluggasminBiz.queryAll());
        view.addObject("columns", CommonPage.setColumnToPage(null,
                null, url, title));
        return view;
    }
    /*月记录*/
    @RequestMapping("/FluggasmothRecordData")
    @ResponseBody
    public CommonResult FluggasmothRecordData(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response) {
        CommonResult commonResult = this.fluggasminBiz.queryMothFluggasDischargeRealdataRecord(commonPage,request,response);
        if (commonResult.getIsSuccess()) {
            commonResult.setData(commonPage);
        }
        return commonResult;
    }

    /*年记录*/
    @RequestMapping(value = "/fluggasRecordyearList")
    public ModelAndView fluggasRecordyearList() {
        ModelAndView view = new ModelAndView("fluggasRecord/fluggasyearList");
        String url = null;
        String title = null;
        Map<Integer, String> map = dictionaryBiz.queryDictionaryByParent(  DictionaryEnums.COMPANY_TYPE.getCode());
        view.addObject("deviceType", GetKeyByValue.getKey(map, "废气排放口"));
        view.addObject("count",fluggasminBiz.queryAll());
        view.addObject("columns", CommonPage.setColumnToPage(null,
                null, url, title));
        return view;
    }
    /*年记录*/
    @RequestMapping("/FluggasyearRecordData")
    @ResponseBody
    public CommonResult FluggasyearRecordData(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response) {
        CommonResult commonResult = this.fluggasminBiz.queryYearFluggasDischargeRealdataRecord(commonPage,request,response);
        if (commonResult.getIsSuccess()) {
            commonResult.setData(commonPage);
        }
        return commonResult;
    }
}
